home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlibs.zip / MEMRCHR.C < prev    next >
Text File  |  1993-01-04  |  769b  |  29 lines

  1.  
  2. /*  File   : memrchr.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 25 May 1984
  5.     Defines: memrchr()
  6.  
  7.     memrchr(src, chr, len)
  8.     searches the memory area pointed to by src extending for len bytes,
  9.     looking for an occurrence of the byte value chr.  It returns NullS
  10.     if there is no such occurrence.  Otherwise it returns a pointer to
  11.     the LAST such occurrence.
  12.  
  13.     See the "Character Comparison" section in the READ-ME file.
  14. */
  15.  
  16. #include <stdio.h>
  17.  
  18. char *memrchr(src, chr, len)
  19.     register char *src;
  20.     register char chr;           /* should be char */
  21.     register int len;
  22.     {
  23.         register char *ans;
  24.         for (ans = NULL; --len >= 0; src++)
  25.             if (*src == chr) ans = src;
  26.         return ans;
  27.     }
  28.  
  29.